Two bytes. For ease in doing IO, booleans are represented using one byte (look at the documentation).
Java documentation sometimes
uses the terms "low byte" and "high byte".
These are used when a data type uses
more than one byte.
The low byte is the byte that
holds the
least significant part of an integer.
If you think in terms of writing a bit pattern
on paper, the low byte is the
rightmost eight bits.
A short
holds a 16-bit pattern
such as:
01001010 00001111
The low order byte is 00001111
.
(The space between the groups is there for readability).
For integer types,
the low order byte holds the part of the number that
consists of powers of two from 0 to 7.
An integer value from 0 to 255 will fit into just the
low byte.
For example, here is the bit pattern for an int
that holds the value 98:
00000000 00000000 00000000 01100010
If this int
is written out with
writeInt()
, the
bytes are written from high byte to low byte
(or from left to right in the above pattern).
For the most part you don't need to think about this unless you are doing serious systems programming. A course in assembly language or computer architecture will say much more about bit patterns.
How many bytes are written by the following:
out.writeInt( 0 ); out.writeDouble( 12.45 );